home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2007 December
/
PCWKCD1207B.iso
/
Blogowanie poza sfera
/
Flock 0.9.1.3 stable
/
flock-0.9.1.3.en-US.win32.exe
/
flock
/
components
/
flockXPCOMTemplate.js.lib
< prev
next >
Wrap
Text File
|
2007-10-12
|
3KB
|
95 lines
// boiler-plate xpcom module
// vim: cindent filetype=javascript
//
// BEGIN FLOCK GPL
//
// Copyright Flock Inc. 2005-2007
// http://flock.com
//
// This file may be used under the terms of of the
// GNU General Public License Version 2 or later (the "GPL"),
// http://www.gnu.org/licenses/gpl.html
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// END FLOCK GPL
//
const WEB_SERVICE_CATEGORY = 'flock-favorites-web-service';
// JavaScript XPCOM Boilerplate /*{{{*/
function xpcomModule (aCID, aContractId, aComponentName, aConstructor) {
this.mCID = Components.ID (aCID);
this.mContractId = aContractId;
this.mComponentName = aComponentName;
this.mConstructor = aConstructor;
this.mGlobalJavascript = null;
this.mFavoritesWebService = null;
// factory object
this.mFactory = {
constructor: this.mConstructor,
createInstance: function (aOuter, aIID) {
if (aOuter != null) {
throw Components.results.NS_ERROR_NO_AGGREGATION;
}
return (new (this.constructor) ()).QueryInterface (aIID);
}
};
}
xpcomModule.prototype = {
setGlobalJavaScript: function (aGlobalJavaScript) {
this.mGlobalJavaScript = aGlobalJavaScript;
},
setFavoritesWebService: function (aFavoritesWebService) {
debug ('setFavoritesWebService("'+aFavoritesWebService+'")\n');
this.mFavoritesWebService = aFavoritesWebService;
},
// the module should register itself
registerSelf: function (aCompMgr, aLocation, aLoaderStr, aType) {
aCompMgr = aCompMgr.QueryInterface (
Components.interfaces.nsIComponentRegistrar);
aCompMgr.registerFactoryLocation (this.mCID, this.mComponentName,
this.mContractId, aLocation, aLoaderStr, aType);
var catmgr = Components.classes["@mozilla.org/categorymanager;1"]
.getService (Components.interfaces.nsICategoryManager);
if (this.mGlobalJavaScript) {
catmgr.addCategoryEntry ("JavaScript global property",
this.mGlobalJavaScript, this.mContractId, true, true);
}
if (this.mFavoritesWebService) {
debug ('adding category entry in "'+WEB_SERVICE_CATEGORY+'"\n');
catmgr.addCategoryEntry (WEB_SERVICE_CATEGORY,
this.mFavoritesWebService, this.mContractId, true, true);
}
},
// get the factory
getClassObject: function (aCompMgr, aCID, aIID) {
if (!aCID.equals (this.mCID)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
if (!aIID.equals (Components.interfaces.nsIFactory)) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}
return this.mFactory;
},
canUnload: function(compMgr) {
return true;
}
};